<?php

if (isset($_GET['act']) && $_GET['act'] == 'ads' && isset($_POST['edit']) && $_POST['edit'] == 1) {
    $datas = $_POST;
    $data = $datas['ads'];
    if (!isset($data['search'])) {
        $data['search'] = $data['search'];
    }
    $data['end_ad'] = htmlspecialchars_decode($data['end_ad']);
    if (get_magic_quotes_gpc()) {
        $data['end_ad'] = stripslashes($data['end_ad']);
    }
    $data['top_ad'] = htmlspecialchars_decode($data['top_ad']);
    if (get_magic_quotes_gpc()) {
        $data['top_ad'] = stripslashes($data['top_ad']);
    }
    if (file_put_contents('../data/aik.ads.php', '<?php
 $ads =  ' . var_export($data, true) . ';
?>')) {
        $tips = '<span class="green" style="font-size:18px; margin-bottom:15px; display:block;">修改成功！</span>';
    } else {
        $tips = '<span class="red" style="font-size:18px; margin-bottom:15px;display:block;">修改失败！可能是文件权限问题，请给予data/aik.ads.php写入权限</span>';
    }
    $aik = $data;
}
if (isset($_GET['act']) && $_GET['act'] == 'setting' && isset($_POST['edit']) && $_POST['edit'] == 1) {
    $datas = $_POST;
    $data = $datas['aik'];
    $data['description'] = strip_tags($data['description']);
    $data['foot'] = htmlspecialchars_decode($data['foot']);
    if (get_magic_quotes_gpc()) {
        $data['foot'] = stripslashes($data['foot']);
    }
    $data['hometopnotice'] = htmlspecialchars_decode($data['hometopnotice']);
    if (get_magic_quotes_gpc()) {
        $data['hometopnotice'] = stripslashes($data['hometopnotice']);
    }
    $data['hometopright'] = htmlspecialchars_decode($data['hometopright']);
    if (get_magic_quotes_gpc()) {
        $data['hometopright'] = stripslashes($data['hometopright']);
    }
    $data['homelink'] = htmlspecialchars_decode($data['homelink']);
    if (get_magic_quotes_gpc()) {
        $data['homelink'] = stripslashes($data['homelink']);
    }
    $data['sort'] = trim($data['sort'], ',');
    if ($data['sort'] == '') {
        $data['sort'] = '1,2,3,4,5,6,7,8,9,10';
    }
    if (!isset($datas['aik']['joinhotkey'])) {
        $data['joinhotkey'] = '0';
    }
    if ($data['admin_pass'] == '') {
        $data['admin_pass'] = $aik['admin_pass'];
    } else {
        $data['admin_pass'] = md5ff(htmlspecialchars($data['admin_pass']));
    }
    if (file_put_contents('../data/beipy.inc.php', '<?php
 $aik =  ' . var_export($data, true) . ';
?>')) {
        $tips = '<span class="green" style="font-size:18px; margin-bottom:15px; display:block;">修改成功！</span>';
    } else {
        $tips = '<span class="red" style="font-size:18px; margin-bottom:15px;display:block;">修改失败！可能是文件权限问题，请给予data/beipy.inc.php写入权限</span>';
    }
    $aik = $data;
}
function deleteAll($xzv_1)
{
    $xzv_0 = dir($xzv_1);
    while (false != ($xzv_2 = $xzv_0->read())) {
        if ($xzv_2 == '.' || $xzv_2 == '..') {
            continue;
        }
        if (is_dir($xzv_0->path . '/' . $xzv_2)) {
            deleteAll($xzv_0->path . '/' . $xzv_2);
            rmdir($xzv_0->path . '/' . $xzv_2);
        } else {
            unlink($xzv_0->path . '/' . $xzv_2);
        }
    }
    echo '<span style="font-size:22px; color:green">清除完毕！</span>';
    closedir($xzv_0);
} ?>